﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ReAnimation.Infrastructure.Services.Interfaces;
using ReAnimation.MVP.ViewInterfaces;

namespace ReAnimation.MVP.Views
{
    public partial class ApplicationSettingsView : BaseFormView, IApplicationSettingsView
    {
        IApplicationSettings _applicationSettings;
        IMoleculesVisualizationSettingsView _moleculesVisualizationSettingsView;
        public ApplicationSettingsView(IApplicationSettings applicationSettings,
            IMoleculesVisualizationSettingsView moleculesVisualizationSettingsView)
        {
            _moleculesVisualizationSettingsView = moleculesVisualizationSettingsView;

            _applicationSettings = applicationSettings;
            InitializeComponent();

            InternalInit();

            ffmpegParamsTextBox.Text = _applicationSettings.FfmpegParams;
            povRayPathTextBox.Text = _applicationSettings.PovRayPath;
            povRayParamsTextBox.Text = _applicationSettings.PovRayParams;
            backColorPanel.BackColor = _applicationSettings.BackgroundColor;
        }

        private void InternalInit()
        {
            var moleculesVisualizationSettingsControl = _moleculesVisualizationSettingsView as UserControl;
            moleculesVisualizationSettingsControl.Dock = DockStyle.Fill;
            tabPage2.Controls.Add(moleculesVisualizationSettingsControl);
        }

        private void backColorPanel_Click(object sender, EventArgs e)
        {
            if (colorDialog1.ShowDialog() == DialogResult.OK)
            {
                backColorPanel.BackColor = colorDialog1.Color;
            }
        }

        private void applyBtn_Click(object sender, EventArgs e)
        {
            _applicationSettings.FfmpegParams = ffmpegParamsTextBox.Text;
            _applicationSettings.PovRayPath = povRayPathTextBox.Text;
            _applicationSettings.PovRayParams = povRayParamsTextBox.Text;
            _applicationSettings.BackgroundColor = backColorPanel.BackColor;
        }
    }
}
